package com.example.siyun.service.impl.productserviceimpl;

import com.example.siyun.mapper.productmapper.JsProductMapper;
import com.example.siyun.pojo.*;
import com.example.siyun.service.productservice.JsProductService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/*
 * 商品列表
 * @author：刘宝龙
 *@Date: 2022-10-12
 * */

@Service
public class JsProductServiceImpl implements JsProductService {

    @Autowired
    private JsProductMapper jsProductMapper;

    /**
     *     右表的增删改查
     */



    /**
     * 全查
     * @return
     */
    @Override
    public List<JsProduct> getAll() {
        return jsProductMapper.getAll();
    }

    /**
     * 添加
     * @param jsProduct
     * @throws Exception
     */
    @Override
    public void insert(JsProduct jsProduct) throws Exception {
        jsProductMapper.insert(jsProduct);
    }

    /**
     * 删除
     * @param productId
     * @throws Exception
     */
    @Override
    public void delete(Integer productId) throws Exception {
        jsProductMapper.delete(productId);
    }

    /**
     * 修改
     * @param jsProduct
     * @throws Exception
     */
    @Override
    public void update(JsProduct jsProduct) throws Exception {
        int num = jsProductMapper.update(jsProduct);
        if (num == 0){
            throw new Exception();
        }
    }

    @Override
    public int state(int productId, int state) throws Exception {
        return jsProductMapper.state(productId,state);
    }


    /**
     * 全查日志
     * @param productId
     * @return
     */
    @Override
    public List<JsProduct> riZhi(int productId) {
        return jsProductMapper.riZhi(productId);
    }

    /**
     * 审核详情
     * @param id
     * @return
     */
    @Override
    public List<Pshenhe> shxq(int id) {
        return jsProductMapper.shxq(id);
    }

    /**
     * 审核按钮
     * @param pshenhe
     */
    @Override
    public void shenHeAnNiu(Pshenhe pshenhe) {
        jsProductMapper.shenHeAnNiu(pshenhe);
    }
    @Override
    public void psh(int ps, int pid) {
        jsProductMapper.psh(ps,pid);
    }

    /**
     * 商品日志
     * @param
     * @return
     */
    @Override
    public List<Productlog> log() {
        return jsProductMapper.log();
    }


    /**
     * 全查操作日志
     * @param productcaozuo
     * @return
     */
    @Override
    public List<Productcaozuo> find(Productcaozuo productcaozuo) {
        return jsProductMapper.find(productcaozuo);
    }

    /**
     * 删除日志记录
     * @param id
     * @return
     */
    @Override
    public int delRiZhi(int id) {
        return jsProductMapper.delRiZhi(id);
    }

    /**
     * 添加日志记录
     * @param productcaozuo
     * @return
     */
    @Override
    public int addRiZhi(Productcaozuo productcaozuo) {
        return jsProductMapper.addRiZhi(productcaozuo);
    }


}
